﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace ProjectenArtesis.Web
{
    public class Item : IComparable
    {
        [Key]
        public int Id { get; set; }
        public string Name { get; set; }
        public int? ParentId { get; set; }
        public int? Studiepunten { get; set; }

        #region Constructors
        public Item()
        {
            this.Id = 0;
            this.Name = "";
        }
        public Item(int id, string name)
        {
            this.Id = id;
            this.Name = name;
        }
        public Item(int id, string name, int? parentId)
            : this (id, name)
        {
            this.ParentId = parentId;
        }

        public Item(int id, string name, int? parentId, int? studiepunten)
            : this (id, name, parentId)
        {
            this.Studiepunten = studiepunten;
        }
        #endregion

        public override string ToString()
        {
            return this.Name;
        }

        public int CompareTo(object obj)
        {
            if (obj.GetType().Equals(this.GetType()))
            {
                Item anderObject = (Item)obj;
                return this.Name.CompareTo(anderObject.Name);
            }
            throw new ArgumentException("Fout type object -- er worden geen twee Item object vergeleken");
        }

        public int ExtractNumberFromName()
        {
            return 0;
        }

        // mogelijk nog een methode toevoegen?
    }
}